export default {
    props: {
        data: {
            type: Array,
            required: true
        }
    },
    computed: {
        cols() {
            return this.$parent.columns;
        },
        sortData() {
            const keys = this.cols.map(v => v.prop)
            console.log(keys)
            return this.data.map(v => {
                const item = {}
                keys.forEach(k => {
                    item[k] = v[k]
                })
                return item;
            })
        }
    },
    render(h) {
        const trs = this.sortData.map(v => {
            const tds = [];
            for (let k in v) {
                tds.push(h('td', v[k]));
            }
            return h('tr', tds);
        })
        return h('tbody', trs)
    }
}